using System;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;

namespace ThridGroup.ERP.HumanResources
{
    /// <summary>
    /// 入职审核测试数据种子贡献者
    /// </summary>
    public class OnboardingAuditsDataSeedContributor : IDataSeedContributor, ITransientDependency
    {
        private readonly IRepository<OnboardingReviewModel, int> _onboardingRepository;

        public OnboardingAuditsDataSeedContributor(IRepository<OnboardingReviewModel, int> onboardingRepository)
        {
            _onboardingRepository = onboardingRepository;
        }

        public async Task SeedAsync(DataSeedContext context)
        {
            if (await _onboardingRepository.GetCountAsync() <= 0)
            {
                await _onboardingRepository.InsertManyAsync(GetTestData());
            }
        }

        private OnboardingReviewModel[] GetTestData()
        {
            var random = new Random();
            var names = new[] { "张三", "李四", "王五", "赵六", "钱七", "孙八", "周九", "吴十", "郑十一" };
            var levels = new[] { "P3", "P4", "P5", "P6", "P7", "P8", "P9", "P10", "P11" };
            var feedbacks = new[] { "还可以", "最新一轮面试...", "表现优秀", "需要改进", "符合要求" };
            var results = new[] { "入职通过", "待定", "不通过", "需要复试" };
            var interviewers = new[] { "kf1", "admin", "hr001", "manager", "director" };

            var testData = new OnboardingReviewModel[15];

            for (int i = 0; i < 15; i++)
            {
                testData[i] = new OnboardingReviewModel
                {
                    PersonName = names[random.Next(names.Length)] + (i + 1),
                    Phone = "158" + random.Next(10000000, 99999999).ToString(),
                    Sex = random.Next(1, 3), // 1=男, 2=女
                    GradingMatch = levels[random.Next(levels.Length)],
                    InterviewFeedback = feedbacks[random.Next(feedbacks.Length)],
                    InterviewResult = results[random.Next(results.Length)],
                    nterviewNumber = random.Next(1, 6),
                    InterviewTime = DateTime.Now.AddDays(-random.Next(0, 365)),
                    InterviewPeople = interviewers[random.Next(interviewers.Length)]
                };
            }

            return testData;
        }
    }
} 